package com.jianguo.web.controller.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jianguo.common.core.domain.AjaxResult;
import com.jianguo.service.domain.PzService;
import com.jianguo.service.domain.PzSvcontent;
import com.jianguo.service.service.IPzServiceService;
import com.jianguo.service.service.IPzSvcontentService;
import com.jianguo.user.domain.PzUser;
import com.jianguo.user.domain.PzUserAddress;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author xjunjie
 * @date 2024/03/29
 */
@RestController
@RequestMapping("/api/service")
public class ServiceApi {
    @Autowired
    private IPzServiceService service;

    @Autowired
    private IPzSvcontentService contentService;

    @GetMapping("/list")
    public AjaxResult list(String name, String num)
    {
        List<PzService> list = service.list(new LambdaQueryWrapper<PzService>()
                .eq(PzService::getName, name).eq(PzService::getNum, num)
                .orderByAsc(PzService::getSort));
        return AjaxResult.success(list);
    }

    /**
     * 服务详情
     * @param serviceId
     * @return
     */
    @GetMapping("/content/list")
    public AjaxResult ContentList(String serviceId)
    {
        List<PzSvcontent> list = contentService.list(new LambdaQueryWrapper<PzSvcontent>()
                .eq(PzSvcontent::getServiceId, serviceId).orderByAsc(PzSvcontent::getSort));
        return AjaxResult.success(list);
    }

    /**
     * 获取
     * @param serviceId
     * @return
     */
    @GetMapping("/content/byId")
    public AjaxResult ContentHead(String serviceId)
    {
        PzService pzService = service.getById(serviceId);
        return AjaxResult.success(pzService);
    }

}
